import org.apache.commons.beanutils.BeanUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

public class test27 {

    public static void main(String[] args) throws DocumentException, ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException {

        SAXReader sr=new SAXReader();
        Document doc=sr.read("a.xml");
        Element rootElement = doc.getRootElement();
        List<Element> elements = rootElement.elements();
        for (Element element : elements) {
            String className = element.attributeValue("className");
            Class<?> aClass=Class.forName(className);
            Object o = aClass.newInstance();
            List<Element> list = element.elements();
            for (Element e : list) {
                String name = e.attributeValue("name");
                String value = e.attributeValue("value");
                BeanUtils.setProperty(o,name,value);
            }
            System.out.println(o);
        }
    }
    }

